#include<bits/stdc++.h>
#define ONLINE_JUDGE
#define ll long long
#define ull unsigned long long
using namespace std;

const ll N = 25, MOD = 1e9 + 7;

ll dp[N][N], cnt[N];
ll num[N], now;

ll dfs(ll pos, ll sum, bool lead, bool limit) {
    ll ans = 0;
    if (pos == 0) return sum;
    if (!lead && !limit && dp[pos][sum] != -1)  return dp[pos][sum];
    ll up = (limit ? num[pos] : 9);
    for (ll i = 0;i <= up;i++) {
        if (i == 0 && lead)
            (ans += dfs(pos - 1, sum, true, limit && i == up)) %= MOD;
        else if (i == now)
            (ans += dfs(pos - 1, sum + 1, false, limit && i == up)) %= MOD;
        else if (i != now)
            (ans += dfs(pos - 1, sum, false, limit && i == up)) %= MOD;
    }
    if (lead == 0 && limit == 0) dp[pos][sum] = ans;
    return ans;
}

ll f(ll x) {
    ll tt = 0;
    while (x) {
        num[++tt] = x % 10;
        x /= 10;
    }
    memset(dp, -1, sizeof(dp));
    return dfs(tt, 0, true, true);
}

void solve() {
    ll l, r, ans = 0;
    cin >> l >> r;
    for (ll i = 1;i <= 9;i++) {
        now = i;
        (ans += i * ((f(r) - f(l - 1) + MOD) % MOD)) %= MOD;
    }
    cout << ans << '\n';
}

signed main()
{
    // ios::sync_with_stdio(0);
    // cin.tie(0);cout.tie(0);
#ifndef ONLINE_JUDGE
    std::istringstream in(R"()");
    std::cin.rdbuf(in.rdbuf());
#endif
    ll T = 1;
    cin >> T;
    for (ll i = 1;i <= T;i++) {
        solve();
    }
}